
<template>
  <div id="cesiumContainer"></div>
  <router-view />
</template>

<script setup>
import * as Cesium from 'cesium'
import CesiumZh from './tool/cesiumToZh'
import { onMounted,getCurrentInstance } from 'vue';
// import { app } from './main';
import {load3dtiles,update3dtiles} from './tool/load3D.js'
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5YmMwMWQzMS1iZjg4LTRlZDItYTNmZC01MWEyMzk4NmYwNzEiLCJpZCI6MjQwNjA4LCJpYXQiOjE3MjYwMjAyNzR9.oHC1L475KukrHI4ppPwqjJB0rQUbV4cr4le-6m6ceHQ'
let viewer
const {appContext} = getCurrentInstance()
const global = appContext.config.globalProperties
  onMounted(() => {
  viewer = new Cesium.Viewer('cesiumContainer', {
    infoBox: false, //隐藏信息框
    selectionIndicator: false,  //隐藏选中框
    timeline:false,
    animation:false
  })

  CesiumZh.load()
  load3dtiles(viewer,'/src/assets/b3dm/tileset.json',(tileset)=>{
    // 使其贴地
    update3dtiles(tileset)
    
    viewer.zoomTo(tileset)
  })
  global.$viewer = viewer
  // app.config.globalProperties.$viewer = viewer
})

</script>
<style lang="scss">
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
#cesiumContainer{
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}
</style>
